package com.hevs.samplewebapp.server.service;

import java.util.List;

import com.google.appengine.api.datastore.Key;
import com.hevs.samplewebapp.server.dao.DAOFactory;
import com.hevs.samplewebapp.server.entities.MedicalRecord;
import com.hevs.samplewebapp.server.entities.User;

public class MedicalRecordService extends Service {

	/**
	 * Default constructor
	 */
	public MedicalRecordService() {
		super();
	}

	/**
	 * Constructor with specified DAOFactory
	 * 
	 * @param daoFactoryInstance
	 *            factory which is called for DAO instantiation
	 */
	public MedicalRecordService(DAOFactory daoFactoryInstance) {
		super(daoFactoryInstance);
	}

	/**
	 * Get a complete medical record from his identifier
	 * 
	 * @param key identifier
	 * @return medical record
	 */
	public MedicalRecord getMedicalRecord(Key key) {
		return getMedicalRecordDAO().getMedicalRecord(key);
	}


	/**
	 * Add a list of medical records
	 * 
	 * @param medicalRecords list of medical records to be added
	 */
	public void addMedicalRecords(List<MedicalRecord> medicalRecords) {
		getMedicalRecordDAO().add(medicalRecords);
	}


	/**
	 * Update or create a new medical record
	 * 
	 * @param medicalRecord the medical record to be created or updated
	 */
	public void updateMedicalRecord(MedicalRecord medicalRecord) {
		getMedicalRecordDAO().update(medicalRecord);
	}

	/**
	 * Remove a medical record
	 * 
	 * @param medicalRecord
	 *            the medical record to be removed
	 */
	public void removeMedicalRecord(MedicalRecord medicalRecord) {
		getMedicalRecordDAO().remove(medicalRecord);
	}

	/**
	 * Get all medical records
	 * 
	 * @return list of users
	 */
	public List<MedicalRecord> getAllMedicalRecords(User user) {
		return getMedicalRecordDAO().getAll(user);
	}

}
